﻿using System;
using System.Collections.Generic;
using System.Linq;
using Infrastucture;

namespace TimeSplicerModule.DomainModels
{
    public class TaskModel : DomainObject
    {
        #region Fields...
        private Guid _taskGuid;
        private Guid _projectGuid;
        private Guid _categoryGuid;
        private Guid _subCategoryGuid;
        private Guid _priorityGuid;
        private Guid _statusGuid;
        private Guid _createdByGuid;
        private Guid _assignedToGuid;
        private string _name;
        private string _description;
        private double _estimatedHours;
        private DateTime _startedDate;
        private DateTime _dueDate;
        private DateTime _completedDate;
        private DateTime _createdDate;
        private double _hours;
        private double _actualHours;
        private bool _isRecurring;
        private DateTime _lastWorked;
        private bool _isDerived;
        private Guid _derivedFromTaskGuid;
        private DateTime _scheduledDate;
        private ProjectModel _project;
        private ProjectUserModel _assignedTo;
        private UserModel _createdBy;
        private StatusModel _status;
        private PriorityModel _priority;
        private CategoryModel _category;
        private CategoryModel _subCategory;
        private TaskScheduleModel _schedule;
        private List<ProjectUserModel> _projectUsers;
        private List<PriorityModel> _priorities;
        private List<CategoryModel> _categories;
        private List<CategoryModel> _subCategories;
        private List<CategoryModel> _filteredSubCategories;
        private List<TimestampModel> _timestamps;
        #endregion Fields


        #region Properties...
        public Guid TaskGuid
        {
            get { return _taskGuid; }
            set { SetProperty(ref _taskGuid, value); }
        }
        public Guid ProjectGuid
        {
            get { return _projectGuid; }
            set { SetProperty(ref _projectGuid, value); }
        }
        public Guid CategoryGuid
        {
            get { return _categoryGuid; }
            set 
            { 
                SetProperty(ref _categoryGuid, value);

                if (this.CategoryGuid != Guid.Empty && this.SubCategories != null)
                    this.FilteredSubCategories = this.SubCategories.Where(x => x.ParentCategoryGuid == this.CategoryGuid).ToList();
            }
            
        }
        public Guid SubCategoryGuid
        {
            get { return _subCategoryGuid; }
            set { SetProperty(ref _subCategoryGuid, value); }
        }
        public Guid PriorityGuid
        {
            get { return _priorityGuid; }
            set { SetProperty(ref _priorityGuid, value); }
        }
        public string Name
        {
            get { return _name; }
            set { SetProperty(ref _name, value); }
        }
        public string Description
        {
            get { return _description; }
            set { SetProperty(ref _description, value); }
        }
        public double EstimatedHours
        {
            get { return _estimatedHours; }
            set { SetProperty(ref _estimatedHours, value); }
        }
        public DateTime StartedDate
        {
            get { return _startedDate; }
            set { SetProperty(ref _startedDate, value); }
        }
        public DateTime DueDate
        {
            get { return _dueDate; }
            set { SetProperty(ref _dueDate, value); }
        }
        public DateTime CompletedDate
        {
            get { return _completedDate; }
            set { SetProperty(ref _completedDate, value); }
        }
        public DateTime CreatedDate
        {
            get { return _createdDate; }
            set { SetProperty(ref _createdDate, value); }
        }
        public Guid CreatedByGuid
        {
            get { return _createdByGuid; }
            set { SetProperty(ref _createdByGuid, value); }
        }
        public Guid AssignedToGuid
        {
            get { return _assignedToGuid; }
            set { SetProperty(ref _assignedToGuid, value); }
        }
        public bool IsRecurring
        {
            get { return _isRecurring; }
            set { SetProperty(ref _isRecurring, value); }
        }
        [DoNotConvert]
        public double Hours
        {
            get { return _hours; }
            set { SetProperty(ref _hours, value); }
        }
        public double ActualHours
        {
            get { return _actualHours; }
            set { SetProperty(ref _actualHours, value); }
        }
        public DateTime LastWorked
        {
            get { return _lastWorked; }
            set { SetProperty(ref _lastWorked, value); }
        }
        public bool IsDerived 
        {
            get { return _isDerived; }
            set { SetProperty(ref _isDerived, value); }
        }
        public Guid DerivedFromTaskGuid
        {
            get { return _derivedFromTaskGuid; }
            set { SetProperty(ref _derivedFromTaskGuid, value); }
        }
        public Guid StatusGuid
        {
            get { return _statusGuid; }
            set { SetProperty(ref _statusGuid, value); }
        }
        public DateTime ScheduledDate
        {
            get { return _scheduledDate; }
            set { SetProperty(ref _scheduledDate, value); }
        }
        public ProjectModel Project
        {
            get { return _project; }
            set { SetProperty(ref _project, value); }
        }
        public ProjectUserModel AssignedTo
        {
            get { return _assignedTo; }
            set { SetProperty(ref _assignedTo, value); }
        }
        public UserModel CreatedBy
        {
            get { return _createdBy; }
            set { SetProperty(ref _createdBy, value); }
        }
        public StatusModel Status
        {
            get { return _status; }
            set { SetProperty(ref _status, value); }
        }
        public PriorityModel Priority
        {
            get { return _priority; }
            set { SetProperty(ref _priority, value); }
        }
        public CategoryModel Category
        {
            get { return _category; }
            set { SetProperty(ref _category, value); }
        }
        public CategoryModel SubCategory
        {
            get { return _subCategory; }
            set { SetProperty(ref _subCategory, value); }
        }
        public TaskScheduleModel Schedule
        {
            get { return _schedule; }
            set { SetProperty(ref _schedule, value); }
        }
        public List<ProjectUserModel> ProjectUsers
        {
            get { return _projectUsers; }
            set { SetProperty(ref _projectUsers, value); }
        }
        public List<PriorityModel> Priorities
        {
            get { return _priorities; }
            set { SetProperty(ref _priorities, value); }
        }
        public List<CategoryModel> Categories
        {
            get { return _categories; }
            set { SetProperty(ref _categories, value); }
        }
        public List<CategoryModel> SubCategories
        {
            get { return _subCategories; }
            set { SetProperty(ref _subCategories, value); }
        }
        public List<CategoryModel> FilteredSubCategories
        {
            get { return _filteredSubCategories; }
            set { SetProperty(ref _filteredSubCategories, value); }
        }
        public List<TimestampModel> Timestamps
        {
            get { return _timestamps; }
            set { SetProperty(ref _timestamps, value); }
        }
        #endregion Properties
    }
}